package org.feng.fxfront.pages.animal;

import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import lombok.Getter;
import org.feng.fxfront.util.ControlUtil;

/**
 * 动物管理操作按钮组
 *
 * @author feng
 */
@Getter
public class AnimalOperationButtonGroup {

    private final Button addButton;
    private final Button updateButton;
    private final Button deleteButton;
    private final Button refreshButton;

    private final VBox buttonGroupVbox;

    public AnimalOperationButtonGroup(double height, double width) {
        addButton = ControlUtil.genAddButton();
        updateButton = ControlUtil.genUpdateButton();
        deleteButton = ControlUtil.genDeleteButton();
        refreshButton = ControlUtil.genRefreshButton();

        buttonGroupVbox = new VBox();
        HBox hBox = new HBox();
        hBox.setMaxWidth(250);
        buttonGroupVbox.getChildren().add(hBox);

        // 设置外边距，上、右，下，左
        buttonGroupVbox.setPadding(new Insets(10, 0, 12, 0));
        buttonGroupVbox.setAlignment(Pos.TOP_LEFT);
        buttonGroupVbox.setMaxWidth(width);
        buttonGroupVbox.setMaxHeight(height);

        // 空格
        Node spacer1 = new Region();
        HBox.setHgrow(spacer1, Priority.ALWAYS);
        Node spacer2 = new Region();
        HBox.setHgrow(spacer2, Priority.ALWAYS);
        Node spacer3 = new Region();
        HBox.setHgrow(spacer3, Priority.ALWAYS);

        hBox.getChildren().add(addButton);
        hBox.getChildren().add(spacer1);
        hBox.getChildren().add(updateButton);
        hBox.getChildren().add(spacer2);
        hBox.getChildren().add(deleteButton);
        hBox.getChildren().add(spacer3);
        hBox.getChildren().add(refreshButton);
    }
}
